package com.example.photograph.controller;

import java.util.List;

import com.example.photograph.domain.CxSelect;
import com.example.photograph.domain.StatisticsEmploymentPlusVo;
import com.example.photograph.domain.StatisticsEmploymentQuery;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.example.photograph.common.annotation.Log;
import com.example.photograph.common.enums.BusinessType;
import com.example.photograph.domain.SysSchool;
import com.example.photograph.service.ISysSchoolService;
import com.example.photograph.common.core.controller.BaseController;
import com.example.photograph.common.core.domain.AjaxResult;
import com.example.photograph.common.utils.poi.ExcelUtil;
import com.example.photograph.common.core.page.TableDataInfo;

/**
 * 学院管理Controller
 * 
 * @author ruoyi
 * @date 2021-05-01
 */
@Controller
@RequestMapping("/photograph/school")
public class SysSchoolController extends BaseController
{
    private String prefix = "photograph/school";

    @Autowired
    private ISysSchoolService sysSchoolService;

    @RequiresPermissions("photograph:school:view")
    @GetMapping()
    public String school()
    {
        return prefix + "/school";
    }

    /**
     * 查询学院管理列表
     */
    @RequiresPermissions("photograph:school:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysSchool sysSchool)
    {
        startPage();
        List<SysSchool> list = sysSchoolService.selectSysSchoolList(sysSchool);
        return getDataTable(list);
    }

    /**
     * 导出学院管理列表
     */
    @RequiresPermissions("photograph:school:export")
    @Log(title = "学院管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysSchool sysSchool)
    {
        List<SysSchool> list = sysSchoolService.selectSysSchoolList(sysSchool);
        ExcelUtil<SysSchool> util = new ExcelUtil<SysSchool>(SysSchool.class);
        return util.exportExcel(list, "学院管理数据");
    }

    /**
     * 新增学院管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存学院管理
     */
    @RequiresPermissions("photograph:school:add")
    @Log(title = "学院管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysSchool sysSchool)
    {
        return toAjax(sysSchoolService.insertSysSchool(sysSchool));
    }

    /**
     * 修改学院管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysSchool sysSchool = sysSchoolService.selectSysSchoolById(id);
        mmap.put("sysSchool", sysSchool);
        return prefix + "/edit";
    }

    /**
     * 修改保存学院管理
     */
    @RequiresPermissions("photograph:school:edit")
    @Log(title = "学院管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysSchool sysSchool)
    {
        return toAjax(sysSchoolService.updateSysSchool(sysSchool));
    }

    /**
     * 删除学院管理
     */
    @RequiresPermissions("photograph:school:remove")
    @Log(title = "学院管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysSchoolService.deleteSysSchoolByIds(ids));
    }


    /**
     * 查询学院管理列表
     */
    @GetMapping("/listCascade")
    @ResponseBody
    public AjaxResult listCascade( )
    {
        List<CxSelect> cxSelects = sysSchoolService.listCascade();


        return new AjaxResult(AjaxResult.Type.SUCCESS,"成功",cxSelects);
    }

}
